package com.liming.common.pojo.dto.coupon;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.liming.common.serializer.YuanToCentDeserializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * @author liming
 * @date 2025/1/18
 */
@Data
@Schema(description = "新增优惠券参数")
public class AddCouponDTO {

    @Schema(description = "优惠券名称", requiredMode = Schema.RequiredMode.REQUIRED)
    private String name;

    @Schema(description = "优惠券类型（1 满减券， 2 折扣券）", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer discountType;

    @Schema(description = "优惠券折扣值（以分为单位，整数型）", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonDeserialize(using = YuanToCentDeserializer.class)
    private Integer discountAmount;

    @Schema(description = "满减券使用门槛（以分为单位，整数型）", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonDeserialize(using = YuanToCentDeserializer.class)
    private Integer minPurchaseAmount;

    @Schema(description = "优惠券开始时间", requiredMode = Schema.RequiredMode.REQUIRED, format = "date-time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startDate;

    @Schema(description = "优惠券结束时间", requiredMode = Schema.RequiredMode.REQUIRED, format = "date-time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endDate;

    @Schema(description = "优惠券使用次数限制（0 表示无限制）", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer usageLimit;

    @Schema(description = "发放数量（0 表示无限制）", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer quantity;
}
